package command;
import object.Branch;
import object.HEAD;
import object.Repository;
import object.Stage;
import utils.FileDeletion;

import java.io.IOException;

public class InitCommand {
    Repository repo;

    public InitCommand() throws Exception{
        repo = new Repository(".");
    }
    public InitCommand(String path) throws Exception{
        repo = new Repository(path);
    }


    public void excute() throws Exception{
        if(repo.exist()){
            if(repo.isDirectory()){
                FileDeletion.deleteFile(Repository.getGitDir());
            }
            else if(repo.isFile()){
                throw new IOException(".jit is a file, please check");
            }
        }
        repo.createRepo();
        Stage stage = new Stage();
        HEAD head = new HEAD();

        System.out.println("Jit Repository has been initiated successfully.");
    }
}
